<?php
session_start();
if (isset($_SESSION["account"])) {
?>
<?php require_once('common/header.php'); ?>
<?php require_once('common/sidebar.php'); ?> 
<div class="main-content app-content mt-0">
                <div class="side-app">
                    <!--占位-->
                            <div class="card"> </div>
                            <!--占位-->
                    <!-- CONTAINER -->
                    <div class="main-container container-fluid">
                            <div class="row">
                            <div class="col-sm-12 col-md-12">
                                <div class="card">
                                    <div class="card-body pb-0">
                                        <div class="input-group mb-2">
                                            <input type="text" class="form-control" id="search-input" placeholder="请输入订单号/号码/身份证号……">
                                            <span class="input-group-text btn btn-primary" id="search-btn">立即查询</span>
                                        </div>
                                        
                                    </div>
                                    <div class="card-body p-5">
                                        <!--<p class="text-muted mb-0 ps-3">共查询1条数据 (耗时0.04秒)</p>-->
                                    </div>
                                </div>
                                <div class="panel-body tabs-menu-body p-0 border-0">
                                    <div class="tab-content">
                                        <div class="tab-pane active" id="tab5">
                                            <div class="card">
                                                <div class="card-body">
                                                    <div class="mb-2 h4 text-dark " >
                                                        订单信息
                                                    </div>
                                                        <p>订单号:<t id = "oderid"></t></p>
                                                        <p>联系方式:<t id = "phones"></t></p>
                                                        <p>身份证号:<t id = "uid"></t></p>
                                                        <p>订单状态:<t id = "status"></t></p>
                                                        <p>下单时间:<t id = "time"></t></p>
                                                </div>
                                            </div>
                                            <div class="card">
                                                <div class="card-body">
                                                    <div class="mb-2 h4 text-dark " >
                                                        其他信息
                                                    </div>
                                                        <p>推广人:<t id = "tgaccount"></t></p>
                                                        <p>产品名称:<t id = "goods"></t></p>
                                                        <p>办理号码:<t id = "thirdphone"></t></p>
                                                        <p>办理ICCID:</p>
                                                        <p>订单备注:<t id = "notes"></t></p>
                                                </div>
                                            </div>
                                        </div>
                                       
                                </div>
                              
                            </div>
                        </div>
                        <!-- End Row -->
                    </div>
                    <!-- CONTAINER CLOSE -->
                    <script src="assets/js/jquery.min.js"></script>
                    <script>
                    $(document).ready(function () {
                        $('#search-btn').click(function () {
                            var searchValue = $('#search-input').val();
                            $.ajax({
                                url: 'controller/OrderSearch.php',
                                type: 'POST',
                                data: {searchValue: searchValue},
                                success: function (response) {
                                var data = JSON.parse(response);
                                // console.log(data);
                                if (data.status === 'error') {
                                    // 处理错误情况
                                    alert(data.msg);
                                } else {
                                    // 将 status 转换为文字描述
                                    var statusText = '';
                                    switch (data.status) {
                                        case '0':
                                            statusText = '未处理';
                                            break;
                                        case '1':
                                            statusText = '已下单';
                                            break;
                                        case '2':
                                            statusText = '已发货';
                                            break;
                                        case '3':
                                            statusText = '已完成';
                                            break;
                                        case '4':
                                            statusText = '开卡失败';
                                            break;
                                        default:
                                            statusText = '未知状态';
                                    }
                            
                                    // 渲染数据到页面上
                                    $('#oderid').text(data.oderid);
                                    $('#phones').text(data.phones);
                                    $('#uid').text(data.uid);
                                    $('#status').text(statusText);
                                    $('#name').text(data.name);
                                    $('#time').text(data.time);
                                    $('#tgaccount').text(data.tgaccount);
                                    $('#goods').text(data.goods);
                                    $('#thirdphone').text(data.thirdphone);
                                    $('#iccid').text(data.iccid);
                                    $('#notes').text(data.notes);
                                }
                            }


                            });
                        });
                    });
                </script>
 <?php require_once('common/footer.php'); ?>   
  <?php
} else {
  echo "<script>alert('登录过过期，没有权限访问该页面');location.href='login.html';</script>";
}